package org.openspml.providers.one_c.api.users;

import java.util.List;

import com.jacob.com.Dispatch;
import com.jacob.com.Variant;

/**
 * 
 * @author <A href="mailto:abashev at gmail dot com">Alexey Abashev</A>
 * @version $Id$
 */
public class InfoBaseUsersManager extends Dispatch {
	public InfoBaseUsersManager(Dispatch dispatch) {
		super(dispatch);
	}
	
	public InfoBaseUser currentUser() {
		return new InfoBaseUser(Dispatch.call(this, "CurrentUser").toDispatch());
	}
	
	public InfoBaseUser findByName(String name) {
		Variant variant = Dispatch.call(this, "FindByName", name);

		if (variant.getvt() == Variant.VariantEmpty) {
			return null;
		}
		
		return new InfoBaseUser(variant.toDispatch());
	}

	public List<InfoBaseUser> getUsers() {
		return new InfoBaseUserList(Dispatch.call(this, "GetUsers").toDispatch());
	}
	
	public String findByUUID() {
		throw new UnsupportedOperationException();
	}
	
	public InfoBaseUser createUser() {
		return new InfoBaseUser(Dispatch.call(this, "CreateUser").toDispatch());
	}
}
